# -*-coding utf-8 -*-

__project__ = 'le-bo16'
__file_name__ = 'pymysql2'
__author__ = 'hqDu'
__time__ = '2020-12-02 2:16'
__product_name = 'PyCharm'
# @fileName :pymysql2.py

# 1.导入pymysql
from pymysql import *

def update_data():
    # 2.创建connection
    # 不加关键字，端口号必须放在最后
    conn = connect('49.233.39.160', 'user', 'leboAa!#$123', 'lebo16', 3306)

    # 3.创建游标
    cur = conn.cursor()

    # 4.更新数据
    # 符合PEP8原则，里头单引号，外头双引号，再外面3引号
    sql = "update students1 set name = 'liuliu' where id = 1;"
    count = cur.execute(sql)
    conn.commit()
    print(count)

    cur.close()
    conn.close()

update_data()